package com.lemon.exam.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

/**
 * WebClient 配置类
 *
 * @author Lemon
 * @since 2025/11/2 13:28
 */
@Configuration
public class WebClientConfiguration {
    @Bean
    public WebClient.Builder webClientBuilder() {
        return WebClient.builder();
    }

    @Bean("webClient")
    public WebClient webClient() {
        return webClientBuilder().build();
    }

    @Bean("sseClient")
    public WebClient sseClient() {
        return webClientBuilder()
                .codecs(configurer -> {
                    // 增加缓冲区大小以支持长连接
                    configurer.defaultCodecs().maxInMemorySize(1024 * 1024); // 1MB
                })
                .build();
    }

}
